package com.ctrip.ec.biz.dao.store;
import com.ctrip.ec.dal.DaoBase;
import com.ctrip.ec.biz.entity.store.StoreEntity;
import com.ctrip.ec.dal.DbAccess;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

@Service
public class StoreDao extends DaoBase<StoreEntity> {
    public StoreDao() {
        super(StoreEntity.class);
    }
    public StoreDao(DbAccess db) {
        super(StoreEntity.class,db);
    }

    public StoreEntity entityByUserId(Long userId) throws SQLException {
        String sql = "select * from " + this.getTableName() + " where user_id = ?";
        List<StoreEntity> list = db.query(StoreEntity.class,sql, userId);
        if(list.size()>0){
            return list.get(0);
        }
        else{
            return null;
        }
    }
}
